package com.woniu.controller;

import com.woniu.entity.Class;
import com.woniu.service.ClassService;
import com.woniu.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/class")
@AllArgsConstructor
public class ClassController {

    private ClassService classService;
    @GetMapping("/queryClassAll")
    public ResponseData<?> queryClassAll(){
        List<Class> classes = classService.queryClass();
        return ResponseData.ok(classes);
    }

    @GetMapping("/queryMy")
    public ResponseData<?> queryMy(){
        List<Class> classes = classService.queryMy();
        return ResponseData.ok(classes);
    }
    @GetMapping("/chooseClass/{classId}")
    public ResponseData<?> chooseClass(@PathVariable("classId") Integer classId){
        Class aClass = classService.chooseClass(classId);
        return ResponseData.ok(aClass);
    }
    @GetMapping("/DeleteClass/{classId}")
    public ResponseData<?> DeleteClass(@PathVariable("classId") Integer classId){
        classService.deleteClass(classId);
        return ResponseData.ok();
    }
    @GetMapping("/queryShow")
    public ResponseData<?> queryShow(){
        List<Class> classes = classService.queryShow();
        return ResponseData.ok(classes);
    }
}
